//
//  PHAnalysis.m
//  PhnixHome
//
//  Created by Levy Xu on 2018/1/5.
//  Copyright © 2018年 Levy Xu. All rights reserved.
//

#import "PHAnalysis.h"

#define kPriceElectricity @"kPriceElectricity"

@implementation PHAnalysis

+(PHAnalysis *)zeroWithDate:(NSDate *)date {
    PHAnalysis *analysis = [[PHAnalysis alloc] init];
    analysis.date = [date stringWithFormat:kYMDFormart];
    analysis.value = 0.0f;
    return analysis;
}

-(NSDate *)myDate {
    return [NSDate date:_date WithFormat:kYMDFormart];
}

-(NSString *)description {
    return [NSString stringWithFormat:@"date: %@, value: %f", _date, _value];
}

+(float)getElectricityPrice {
    if ([NDSUD objectForKey:kPriceElectricity]) {
        return [[NDSUD objectForKey:kPriceElectricity] floatValue];
    }
    return 0.8f;
}

+(void)saveElectricityPrice:(float)price {
    [NDSUD setObject:@(price) forKey:kPriceElectricity];
}

@end
